package com.yugong.controller;

import com.github.pagehelper.PageInfo;
import com.yugong.common.Result;
import com.yugong.entity.vo.request.OrderClassAdminRequestVO;
import com.yugong.entity.vo.request.StudentRequestVO;
import com.yugong.entity.vo.response.CourseScoreListResponseVO;
import com.yugong.entity.vo.response.OrderClassAdminListResponseVO;
import com.yugong.entity.vo.response.StudentListResponseVO;
import com.yugong.service.OrderClassAdminService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

/**
 * 订单班管理员控制器类
 *
 * @author yugong
 * @date 2024/2/18
 */
@RestController
@RequestMapping("/api/order-class-admin")
public class OrderClassAdminController {
    @Resource
    private OrderClassAdminService orderClassAdminService;

    /**
     * 根据姓名查询订单班管理员
     *
     * @param pageNum             当前页
     * @param pageSize            当前页数据总个数
     * @param orderClassAdminName 姓名
     * @return 订单班管理员
     */
    @GetMapping("/find-order-class-admin-page")
    public Result findOrderClassAdminPage(@RequestParam(defaultValue = "1") Integer pageNum,
                                          @RequestParam(defaultValue = "5") Integer pageSize,
                                          @RequestParam String orderClassAdminName) {
        PageInfo<OrderClassAdminListResponseVO> orderClassAdminListResponseVOPageInfo
                = orderClassAdminService.findOrderClassAdmin(pageNum, pageSize, orderClassAdminName);
        return Result.success(orderClassAdminListResponseVOPageInfo);
    }

    /**
     * 删除订单班管理员
     *
     * @param orderClassAdminNo 工号
     * @return 响应码
     */
    @DeleteMapping("/delete-order-class-admin/{orderClassAdminNo}")
    public Result deleteOrderClassAdmin(@PathVariable String orderClassAdminNo) {
        int deleteFlag = orderClassAdminService.deleteOrderClass(orderClassAdminNo);
        return Result.success(deleteFlag);
    }

    /**
     * 查询订单班管理员个人信息
     *
     * @param orderClassAdminNo 工号
     * @return 订单班管理员个人信息
     */
    @GetMapping("/order-class-admin-info/{orderClassAdminNo}")
    public Result orderClassAdminInfo(@PathVariable String orderClassAdminNo) {
        OrderClassAdminListResponseVO orderClassAdminListResponseVO = orderClassAdminService.orderClassAdminInfo(orderClassAdminNo);
        return Result.success(orderClassAdminListResponseVO);
    }

    /**
     * 修改个人信息
     *
     * @param orderClassAdminRequestVO 订单班管理员请求实体类
     * @return 响应码
     */
    @PutMapping("/update-info")
    public Result updateInfo(@RequestBody OrderClassAdminRequestVO orderClassAdminRequestVO) {
        int updateFlag = orderClassAdminService.updateInfo(orderClassAdminRequestVO);
        return Result.success(updateFlag);
    }

    /**
     * 修改订单班管理员
     *
     * @param orderClassAdminRequestVO 订单班管理员请求实体类
     * @return 响应码
     */
    @PutMapping("/update-order-class-admin")
    public Result updateOrderClassAdmin(@RequestBody OrderClassAdminRequestVO orderClassAdminRequestVO) {
        int updateFlag = orderClassAdminService.updateOrderClassAdmin(orderClassAdminRequestVO);
        return Result.success(updateFlag);
    }

    /**
     * 查看学生信息
     *
     * @param pageNum           当前页
     * @param pageSize          当前页总数
     * @param studentName       姓名
     * @param orderClassAdminNo 工号
     * @return 学生信息
     */
    @GetMapping("/find-student/{orderClassAdminNo}")
    public Result findStudent(@RequestParam Integer pageNum,
                              @RequestParam Integer pageSize,
                              @RequestParam String studentName,
                              @PathVariable String orderClassAdminNo) {
        PageInfo<StudentListResponseVO> studentListResponseVOPageInfo
                = orderClassAdminService.findStudent(pageNum, pageSize, studentName, orderClassAdminNo);
        return Result.success(studentListResponseVOPageInfo);
    }

    /**
     * 评价学生
     *
     * @param studentRequestVO 学生请求实体类
     * @return 响应码
     */
    @PutMapping("/evaluate-student")
    public Result evaluateStudent(@RequestBody StudentRequestVO studentRequestVO) {
        int evaluateFlag = orderClassAdminService.evaluateStudent(studentRequestVO);
        return Result.success(evaluateFlag);
    }

    /**
     * 查看成绩
     *
     * @param pageNum           当前页
     * @param pageSize          当前页个数
     * @param studentName       姓名
     * @param orderClassAdminNo 工号
     * @return 成绩
     */
    @GetMapping("/find-score/{orderClassAdminNo}")
    public Result findScore(@RequestParam Integer pageNum,
                            @RequestParam Integer pageSize,
                            @RequestParam String studentName,
                            @PathVariable String orderClassAdminNo) {
        PageInfo<CourseScoreListResponseVO> courseScoreListResponseVOPageInfo
                = orderClassAdminService.findScore(pageNum, pageSize, studentName, orderClassAdminNo);
        return Result.success(courseScoreListResponseVOPageInfo);
    }
}
